﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Models;
using BLL;
namespace AGVControlSystemPro
{
    public partial class FrmNewMap : Form
    {
        //根据委托创建委托对象
        public ShowFileName msgSender;
        public FrmNewMap()
        {
            InitializeComponent();
        }

        private void btnCreate_Click(object sender, EventArgs e)
        {
            #region 数据验证
            if (this.txtFileName.Text.Trim().Length == 0)
            {
                if (CommonMethods.LanguageId == 3) MessageBox.Show("ファイル名は空けてはいけません", "新規ファイル");
                else MessageBox.Show("文件名不能为空", "新建文件");
                return;
            }
            #endregion
            //数据封装
            FileNameAddress objFileNameAddress = new FileNameAddress()
            {
                FileName = this.txtFileName.Text.Trim()
            };
            int result = new FileNameAddressManager().AddFileName(objFileNameAddress);
            //后台数据访问
            if ( result> 0)
            {
                objFileNameAddress.ID = result;
                if (msgSender != null)
                {
                    msgSender(objFileNameAddress);
                }
                this.DialogResult = DialogResult.OK;
                this.Close();
            }           
        }

    }
}
